package cn.donting.jme.swing.drag;

import cn.hutool.core.io.FileUtil;

import java.awt.datatransfer.DataFlavor;
import java.io.File;

public class EditorDataFlavor {
    public static final String filePrefix = "jme/file-";

    public static final DataFlavor spatial = creatDataFlavor("jme/savable-spatial");
    public static final DataFlavor camera = creatDataFlavor("jme/savable-camera");

    public static DataFlavor getFileDataFlavor(File file) {
       return getFileDataFlavor(FileUtil.extName(file));
    }
    public static DataFlavor getFileDataFlavor(String extName) {
        try {
            return new DataFlavor(filePrefix + extName);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
    private static DataFlavor creatDataFlavor(String mineType) {
        try {
            return new DataFlavor(mineType);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
